'''
Created on 2010-3-16

@author: Administrator
'''
import wx
from jolly.visual.vtkPythonViewImage3D import *

try:
    from agw import foldpanelbar as fpb
except ImportError: # if it's not there locally, try the wxPython lib.
    import wx.lib.agw.foldpanelbar as fpb

from jolly.wxext.AbstractModel import *

class PythonViewImage3DModel(AbstractModel):
    '''
    classdocs
    '''


    def __init__(self, view=None, collection=None, frame=None):
        '''
        Constructor
        '''
        AbstractModel.__init__(self)
        
        self._view = view
        self._collection = collection
        self._frame = frame
    
    def SetRenderingModeToPlanar(self):
        self._view.SetRenderingModeToPlanar()
       
    
    def SetRenderingModeToVR(self):
        self._view.SetRenderingModeToVR()
        
    
    

class PythonViewImage3DPanel(wx.Panel):
    '''
    classdocs
    '''
    
    def __init__(self, parent, id, model=None, pos=wx.DefaultPosition, size=wx.DefaultSize,
                 style=wx.NO_BORDER | wx.TAB_TRAVERSAL):
        '''
        '''
        wx.Panel.__init__(self, parent, id, pos, size, style)
        
        self.model = model
        if self.model:
            self.model.addListener(self.UpdateControl)
            
        self.CreateControls()
        self.UpdateControl()
        self.GetSizer().Fit(self)
        self.GetSizer().SetSizeHints(self)
        self.GetSizer().Layout()
        
        self.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption)
    
    def OnPressCaption(self, event):
        event.Skip()
    
    def CreateControls(self):
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        
        subpanel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
                            wx.NO_BORDER | wx.TAB_TRAVERSAL)
        sizer.Add(subpanel, 1, wx.GROW | wx.ADJUST_MINSIZE, 5)
        
        subsizer = wx.GridBagSizer(5, 5)
        subpanel.SetSizer(subsizer)
        
        self.ch1 = wx.Choice(subpanel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ["3D-volume", "Multi-Panel"], 0 )
        subsizer.Add(wx.StaticText(subpanel,-1, "Rendering Mode"), (0,0), flag=wx.ALIGN_CENTER | wx.ALL)
        subsizer.Add(self.ch1, (0,1),(1,2), wx.EXPAND)
        self.Bind(wx.EVT_CHOICE, self.OnChoicedRenderingMode, self.ch1)
    
        
    
    def UpdateControl(self):
        pass
    
    def OnChoicedRenderingMode(self, event):
        print event.GetInt()
        if event.GetInt()==0:
            self.model.SetRenderingModeToVR()
        elif event.GetInt()==1:
            self.model.SetRenderingModeToPlanar()
        
        